package com.example.linyiquan.application.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.linyiquan.application.R;
import com.example.linyiquan.application.beam.AppBeam;

import java.util.List;

/**
 * Created by linyiquan on 17-4-20.
 */

public class GridAdapter extends BaseAdapter {

    public List<AppBeam> items;

    public GridAdapter(Context context, List<AppBeam> items){
        this.items=items;

        this.items.add(new AppBeam("insert app",context.getResources().getDrawable(R.drawable.button)
                ,""));

        this.items.add(new AppBeam("remove app",context.getResources().getDrawable(R.drawable.button)
        ,""));

    }

    @Override
    public int getCount() {
        return items.size();
    }

    @Override
    public Object getItem(int position) {
        return items.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        AppBeam item=items.get(position);
        View view= LayoutInflater.from(parent.getContext()).inflate(R.layout.item,null);
        TextView title= (TextView) view.findViewById(R.id.item_tv);
        ImageView icon=(ImageView)view.findViewById(R.id.item_img);
        icon.setImageDrawable(item.getAppicon());
        title.setText(item.getAppname());
        return view;
    }
}
